from common.basic2 import send_message_to_kafka, upate_meassage_id, save_file, upate_meassage_time
#  报文内容
data = {
    "project": "scan_api",
    "packetType": "http",
    "data": {
        "id": None,
        "agentNodeBusinessMark": "10.10.2.239",
        "httpType": 1,
        "host": "10.10.2.239:32280",
        "port": 32280,
        "httpDirection": None,
        "uri": "/api/system/login",
        "fullUri": "http://10.10.2.239:32280/api/system/login",
        "requestIp": "10.10.2.201",
        "requestMethod": "POST",
        "requestTime": "2023-11-08 16:16:27",
        "requestTimestamp": None,
        "requestTimestampStr": None,
        "requestContentLength": 420,
        "requestContentType": "application/json",
        "requestHeader": "{\"X-Timestamp\":\"123321\",\"X-App-Id\":\"ACCO8lMQ\",\"Version\":\"2.0\",\"X-Sequence-No\":\"123321\",\"Connection\":\"keep-alive\",\"User-Agent\":\"Apache-HttpClient/4.5.13 (Java/1.8.0_302)\",\"X-Forwarded-For\":\"10.10.0.1\",\"Host\":\"10.10.2.239:32280\",\"Content-Length\":\"420\",\"Source-Ip\":\"10.10.2.201\",\"Content-Type\":\"application/json\"}",
        "requestBody": "{\"password\":\"WJiKZsDyePMYoVxv891HVrvb7++e6F3pH686A7OP5M6wDuoyZh77OEp1Tesud1xnDgHizwzNrZBTt8JqU/Glf0oC4lDhUXRE0D6EWq6W9WEdGf4Y10fsZMHt1oUzNfadKLa9lVGUDA6Ljeqpvo+5yIp+KgatMV5y6zb9ZdmHdTY=\",\"captcha\":\"\",\"origin\":0,\"name\":\"JKezzPicUeN4aAPYBWQ08fZKXgft/INvvIf7engde60pwyGj7OWu6tS4xBRBHlevtr88RbF8jhNBFnq6LfAeXvF8LVgvrYaXJcL1PFPSGuetQ/k8Plnlzg0ShRpWW+r4dsM5TOyOpHZuNbZmjiXxWRmGNQH50ATPFPv7/anNys4=\",\"key\":\"\",\"publicKeyId\":\"0\"}",
        "sensitiveChars": None,
        "statusCode": 200,
        "costTime": 201,
        "responseIp": "10.10.2.239",
        "responseTime": "2023-11-08 16:16:27",
        "responseTimestamp": 1699431387681,
        "responseTimestampStr": None,
        "responseContentLength": 420,
        "responseContentType": "application/json",
        "responseHeader": "{\"Transfer-Encoding\":\"chunked\",\"X-Frame-Options\":\"SAMEORIGIN\",\"Destination-Ip\":\"10.10.2.239\",\"Connection\":\"keep-alive\",\"X-XSS-Protection\":\"1;mode=block\",\"Date\":\"Wed, 08 Nov 2023 08:16:27 GMT\",\"Content-Type\":\"application/json\"}",
        "responseBody": "{\"code\":\"200\",\"msg\":\"响应成功\",\"data\":{\"id\":null,\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTk0Mzg1ODcsInVzZXJuYW1lIjoiYXV0b1Rlc3RfMDEifQ.RYvmrX4vzv2p1iJhw-2itIR0jazBJtYNSM_gLCA6c34\",\"expiresTime\":\"2023-11-08 18:16:27\",\"userId\":58736,\"userName\":\"autoTest_01\",\"realName\":\"自动化账号\",\"createTime\":\"2023-11-08 16:16:27\",\"sysManager\":true,\"origin\":1,\"passwordExpireDays\":null,\"userStatus\":\"0\",\"clusterManager\":true}}",
        "complete": True,
        "hasIllegalAsset": False,
        "illegalReason": "",
        "illegalRule": "",
        "referer": "",
        "userAgent": "Apache-HttpClient/4.5.13 (Java/1.8.0_302)",
        "url": "http://10.10.2.239:32280/api/system/login"
	}
}

# 替换ID
upate_meassage_id(data)

# 替换时间错
upate_meassage_time(data)

# 生成文件
pwd = '../filesOutput/一般报文模板-改.txt' # 指定路径
save_file(pwd, data)

# 发送消息到Kafka队列
send_message_to_kafka('10.10.2.236:32200', 'api-neta-parser', data)